<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    
                        
    <ui:composition template="/template.xhtml">
        
        <ui:define name="title">
            <h:outputText value="#{bundle['Users.List.Title']}"></h:outputText>
        </ui:define>
        <ui:define name="menu">
            <div class="block_menu">
                <h:form>
                    <div class="block_menu_left">
                        <h:commandLink action="/index" value="#{bundle['Menu.Main']}"/>
                    </div>
                    <div class="block_menu_left">
                        <h:commandLink action="/notes/List" value="#{bundle['Menu.Notes']}"/>
                    </div>
                    
                    <h:panelGroup rendered="#{userManagerController.isAuthenticated() == 0}">
                        <div class="block_menu_right">
                            <h:commandLink action="/authenticate/Registration" value="#{bundle['Menu.Registration']}"/>
                        </div>

                        <div class="block_menu_right">
                            <h:commandLink action="/authenticate/Login" value="#{bundle['Menu.Login']}"/>
                        </div>
                    </h:panelGroup>
                    <h:panelGroup rendered="#{userManagerController.isAuthenticated() == 1}">
                        <div class="block_menu_right">
                            <h:commandLink action="#{userManagerController.logout()}" value="#{bundle['Menu.Logout']}"/>
                        </div>
                        
                        <div class="block_menu_right">
                            <h:commandLink action="/profile/View" value="Hello #{userManagerController.getAuthenticatedUserName()}"/>
                        </div>     
                        <h:panelGroup rendered="#{userManagerController.isRoleAdmin() == 1}">
                            <div class="block_menu_left">
                                <h:commandLink action="/users/List" value="#{bundle['Menu.UsersManagement']}"/>
                            </div>
                            

                            <div class="block_menu_left_action">
                                <h:commandLink action="Add" value="#{bundle['Menu.AddUser']}"/>
                            </div>  
                        </h:panelGroup>
                    </h:panelGroup>
                </h:form>
            </div>
        </ui:define>
        <ui:define name="body">
            <h:messages errorClass="error" infoClass="info" />
            <br/>
            <center>
                
                
            <h:form styleClass="usersview">
                
                
                <h:outputText escape="false" 
                    style="color: #707070; font: 54pt 'Segoe UI Semilight';" 
                    value="#{bundle['Users.List.Empty']}" 
                    rendered="#{userController.isUsersExist() == 0}"/>
                
                <!--  If users exists show them  -->
                <h:panelGroup rendered="#{userController.isUsersExist() != 0}">
                    
                <h:dataTable value="#{userController.allUser}" var="item" 
                    width="90%" rowClasses="table-row1,table-row2"
                    columnClasses="u_t_1,u_t_2,u_t_3,u_t_4,u_t_5,u_t_6">

                    <h:column>
                        <f:facet name="header">
                            <h:outputText 
                                value="#{bundle['Users.List.Title.Login']}"/>
                        </f:facet>
                        <h:outputText value="#{item.login}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText 
                                value="#{bundle['Users.List.Title.Password']}"/>
                        </f:facet>
                        <h:outputText value="#{item.password}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText 
                                value="#{bundle['Users.List.Title.Email']}"/>
                        </f:facet>
                        <h:outputText value="#{item.email}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText 
                             value="#{bundle['Users.List.Title.Role']}"/>
                        </f:facet>
                        <h:outputText value="#{item.roleSux}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="&nbsp;"/>
                        </f:facet>
                        <h:commandLink action="#{userController.edit}" 
                            value="#{bundle['Users.List.EditLink']} ">
                            <f:setPropertyActionListener 
                                target="#{userController.current_user_id}" 
                                value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                    
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="&nbsp;"/>
                        </f:facet>
                        <h:commandLink action="#{userController.destroy}" 
                            value=" #{bundle['Users.List.DeleteLink']}">
                            <f:setPropertyActionListener 
                                target="#{userController.current_user_id}"
                                value="#{item.id}"/>
                        </h:commandLink>
                    </h:column>
                </h:dataTable>
                </h:panelGroup>

            </h:form>
            </center>
        </ui:define>

    </ui:composition>

</html>
